package com.alibaba.ai.controller;

import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.ai.entity.YPostLike;
import com.alibaba.ai.service.YPostLikeService;

import javax.annotation.Resource;

@Controller
public class YPostLikeController {
    @Resource
    private YPostLikeService yPostLikeService;

    @ResponseBody
    @RequestMapping("/addPostLike")
    public JSONObject addPostLike(Integer yUsersId, Integer yPostId) {
        YPostLike yPostLike=new YPostLike();
        yPostLike.setYUsersId(yUsersId);
        yPostLike.setYUsersId(yPostId);

        boolean bool  = yPostLikeService.addPostLike(yPostLike);
        JSONObject json = new JSONObject();
        json.put("bool", bool);
        return json;

    }

    @ResponseBody
    @RequestMapping("/addPostUnLike")
    public JSONObject addPostUnLike(Integer yUsersId, Integer yPostId) {
        YPostLike yPostLike=new YPostLike();
        yPostLike.setYUsersId(yUsersId);
        yPostLike.setYUsersId(yPostId);

        boolean bool  = yPostLikeService.addPostLike(yPostLike);
        JSONObject json = new JSONObject();
        json.put("bool", bool);
        return json;

    }
}